function []=CPTKals_Demo()
ClearHistory;
addpath(genpath('C:\Program Files\MATLAB\R2013b\toolbox\tensor_toolbox'));
addpath(genpath('C:\Users\wanglele\Desktop\0628\tensor_toolbox'));
addpath(genpath('C:\Program Files\MATLAB\R2013b\toolbox\poblano_toolbox'));
addpath(genpath('C:\Program Files\MATLAB\R2013b\toolbox\CMTF_Toolbox'));
%Alternating least squares for PARAFAC/CANDECOMP
rand('state',0);
X = sptenrand([100 100 100], 10000);
P = parafac_als(X,2,struct('dimorder',[3 2 1],'init','nvecs'));
norm(full(P)-full(X))/norm(full(X))

%Alternating least squares for Tucker model
T = tucker_als(X,2,struct('dimorder',[3 2 1],'init','eigs'));
norm(full(T)-full(X))/norm(full(X))
end